require("../../utils/util.js");

var e = require("../../requests/request.js");

Component({
    properties: {
        modelid: {
            type: String,
            value: ""
        },
        modelname: {
            type: String,
            value: ""
        }
    },
    data: {
        modelshow: !1,
        modelList: {},
        initails: [],
        loading: !1
    },
    methods: {
        markmove: function() {},
        hideDialog: function() {
            this.setData({
                modelList: {},
                initails: [],
                modelshow: !this.data.modelshow
            });
        },
        showDialog: function(t, r) {
            var a = this;
            e.getSerialList(t, function(e) {
                for (var i = e, n = [], s = [], o = [], c = 0; c < i.length - 1; c++) {
                    if (i[c].Picture ? i[c].Picture = i[c].Picture.replace("{0}", 6) : i[c].Picture = "http://res.app.yiche.com/wechatapp/async100x100.png", 
                    n.contains2(i[c].BrandName) || n.push(i[c].BrandName), "" != i[c].DealerPrice && "暂无报价" != i[c].DealerPrice && "暂无" != i[c].DealerPrice || (i[c].DealerPrice = i[c].ReferPrice), 
                    i[c].DealerPrice && i[c].DealerPrice.indexOf("-")) {
                        var l = i[c].DealerPrice.split("-");
                        l && l.length > 1 && l[0] == l[1] && (i[c].DealerPrice = l[0]);
                    }
                    i[c].PriceName = i[c].DealerPrice;
                }
                n.forEach(function(e) {
                    var t = i.filter(function(t) {
                        return t.BrandName == e;
                    }).sort(function(e, t) {
                        return t.UV - e.UV;
                    });
                    s.push({
                        Name: t[0].BrandName,
                        Uv: t[0].UV
                    });
                }), s.sort(function(e, t) {
                    return t.Uv - e.Uv;
                });
                for (c = 0; c < s.length; c++) o.push(s[c].Name);
                a.setData({
                    modelList: i.slice(0, i.length - 1).sort(function(e, t) {
                        return t.UV - e.UV;
                    }),
                    initails: o,
                    modelid: t,
                    modelname: r
                });
            }, null, function() {
                a.setData({
                    loading: !1
                });
            }), a.setData({
                modelshow: !a.data.modelshow
            });
        },
        _gosummary: function(e) {
            var t = {
                id: e.currentTarget.dataset.id,
                name: e.currentTarget.dataset.name,
                price: e.currentTarget.dataset.price,
                pic: e.currentTarget.dataset.carpic
            }, r = this;
            this.triggerEvent("myevent", t, r);
        }
    }
});